package cn.com.bluemoon.daps.common.domain;

import java.io.Serializable;
import java.util.Collections;
import java.util.List;

/**
 * 简单分页模型
 */
public class PageVo<T> implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 查询数据列表
     */
    private List<T> content = Collections.emptyList();

    /**
     * 总数
     */
    private long total = 0;
    /**
     * 每页显示条数，默认 10
     */
    private long size = 10;

    /**
     * 当前页
     */
    private long current = 1;


    public PageVo() {
    }

    /**
     * 分页构造函数
     *
     * @param current 当前页
     * @param size    每页显示条数
     */
    public PageVo(long current, long size) {
        this(current, size, 0);
    }

    public PageVo(long current, long size, long total) {
        this.current = current;
        this.size = size;
        this.total = total;
    }

    /**
     * 是否存在上一页
     *
     * @return true / false
     */
    public boolean hasPrevious() {
        return this.current > 1;
    }

    /**
     * 是否存在下一页
     *
     * @return true / false
     */
    public boolean hasNext() {
        return this.current < this.getTotal();
    }

    public List<T> getContent() {
        return this.content;
    }

    public PageVo<T> setContent(List<T> records) {
        this.content = records;
        return this;
    }

    public long getTotal() {
        return this.total;
    }

    public PageVo<T> setTotal(long total) {
        this.total = total;
        return this;
    }

    public long getSize() {
        return this.size;
    }

    public PageVo<T> setSize(long size) {
        this.size = size;
        return this;
    }

    public long getCurrent() {
        return this.current;
    }

    public PageVo<T> setCurrent(long current) {
        this.current = current;
        return this;
    }

}
